import { defineStore } from "pinia";
import { login } from "@/apis/login/index.js";
import { reactive, ref } from "vue";

export const useLoginStore = defineStore("login", () => {
	const formData = reactive({
		userName: "",
		passWord: "",
	});
	// const status = ref()
	// const token = ref('')
	const res = reactive({
		code: String,
		message: String,
		token: String,
	});
	const toLogin = async (data) => {
		const response = await login(data);
		res.code = response.code;
		res.message = response.message;
		res.token = response.data;
	};

	return {
		formData,
		res,
		toLogin,
	};
});
